package com.woniu.project.web.common;

import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.time.LocalDate;

/**
 * @Author: Klaus
 * @Date: 2020/10/13 18:44
 */
public class DateCommon {

    //将date格式 转为LocalDate格式
    public static LocalDateTime getLocalDate(Date date){
        //获取当前时间并转换其格式
        DateTimeFormatter fmt = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        //设置要获取到什么样的时间
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        //获取String类型的时间
        String createdate = sdf.format(date);
        LocalDateTime nowLocalDate = LocalDateTime.parse(createdate, fmt);
        return nowLocalDate;
    }
}
